package hos.table.model;

import androidx.annotation.NonNull;

import java.util.Objects;

/**
 * <p>Title: Content </p>
 * <p>Description:  </p>
 * <p>Company: www.mapuni.com </p>
 *
 * @author : 蔡俊峰
 * @version : 1.0
 * @date : 2022/7/6 22:19
 */
public class TableInfo {
    private final String id;
    private final Object data;
    private Object extra;

    private int background;

    private int textColor;

    private int textBackground;

    public TableInfo(String id, Object data) {
        this.id = id;
        this.data = data;
    }

    public TableInfo(Object data) {
        this(String.valueOf(System.currentTimeMillis()) + data.hashCode(), data);
    }

    public TableInfo with(int background, int textColor, int textBackground) {
        this.background = background;
        this.textColor = textColor;
        this.textBackground = textBackground;
        return this;
    }

    @NonNull
    public String getId() {
        return id;
    }

    @NonNull
    public Object getContent() {
        return data;
    }

    @NonNull
    public <T> T getData(Class<T> clazz) {
        return Objects.requireNonNull(clazz.cast(data));
    }

    @NonNull
    public Object getExtra() {
        return extra;
    }

    public void setExtra(Object extra) {
        this.extra = extra;
    }

    public int getBackground() {
        return background;
    }

    public void setBackground(int background) {
        this.background = background;
    }

    public int getTextColor() {
        return textColor;
    }

    public void setTextColor(int textColor) {
        this.textColor = textColor;
    }

    public int getTextBackground() {
        return textBackground;
    }

    public void setTextBackground(int textBackground) {
        this.textBackground = textBackground;
    }
}
